	<?php get_header(); ?>
    
    <?php 
        function object_array($array) {  
            if(is_object($array)) {  
                $array = (array)$array;  
             } if(is_array($array)) {  
                 foreach($array as $key=>$value) {  
                     $array[$key] = object_array($value);  
                     }  
             }  
             return $array;  
        } 
        //var_dump(the_category());
        if(is_home()){ 
            //引入活动流程与MID图
            get_template_part( 'time_mid');
    ?>
        <section class="message">
            <div class="msg_center">
                <div class="column_name">
                    活动动态
                </div>
                <div class="news">
                    <div class="pic_news">
                        <img src="<?php bloginfo('template_directory'); ?>/img/pic_news.jpg" alt="">
                    </div>
                    <div class="word_news">
                        <?php 
                            //渲染中间文章
                            if(is_home()){
                                $options=array(
                                    //显示三篇文章
                                    'numberposts' => 3,
                                    //categoryID应该是活动动态目录ID
                                    'category' => 5
                                );
                                $content_arr=get_posts($options);
                                foreach ($content_arr as $item) {
                                    $item=object_array($item);
                                    //控制输出字符串长度
                                    if(strlen($item["post_title"])>75){
                                        $item["post_title"]=substr($item["post_title"], 0,75)."...";
                                    };
                                    $item["post_content"]=preg_replace("/\[video.*\]/","",$item["post_content"]);
                                    $item["post_content"]=preg_replace("/\[caption.*\]/","",$item["post_content"]);
                                    $item["post_content"]=preg_replace("/<[^>]*>/","",$item["post_content"]);
                                    $item["post_content"]=substr($item["post_content"] , 0 , 290)."...";
                                    

                                    //DOM结构如下模板
                                    echo "<div><p><a href='".$item['guid']."'>".$item["post_title"]."</a></p><p>".$item["post_content"]."</p></div>";
                                };
                            }
                        ?>
                    </div>
                    
                </div>
                <div class="more"> 
                    <a href="http://sci3min.cn/category/media/">查看更多&gt;&gt;</a>
                </div>
                <div class="video_news">
                		<?php 
                			$options=array(
                                    //显示三篇文章
                                    'numberposts' => 4,
                                    //categoryID应该是媒体中心目录ID
                                    'category' => 3
                                );
                                $content_arr=get_posts($options);
                                foreach ($content_arr as $item) {
                                	$item=object_array($item);
                                	$item["post_content"]=preg_replace("/<p>/","",$item["post_content"]);
                                	$item["post_content"]=preg_replace("/<\/p>/","",$item["post_content"]);
                                	$item["post_content"]=preg_replace("/500/","240",$item["post_content"]);
                                	$item["post_content"]=preg_replace("/375/","180",$item["post_content"]);
                                	$item["post_content"]=preg_replace("/640/","240",$item["post_content"]);
                                	$item["post_content"]=preg_replace("/498/","180",$item["post_content"]);
                                	$item["post_content"]=preg_replace("/name/","id='name".$item['ID']."'",$item["post_content"]);
                                	echo "<div style='position:relative'><div style='position:absolute;width:100%;height:100%;z-index:999'  onclick='window.location.href=\"".$item["guid"]."\"'></div>".$item["post_content"]."<p style='text-align:center;'>".$item["post_title"]."</p></div>";
                                	echo "<script>$('#name".$item['ID']."').contents().find('.txp_tipbar').hide();console.log(0)</script>";

                                }

                		?>
                </div>
            </div>
        </section>
        
    <?php 
        //引入支持媒体模板
        get_template_part('sup_media');    
        } 

    ?>

	<?php 
	?>
	<?php
    //投票
        if(is_page('xstp')){
            get_template_part('vote');      
        }
    //赛事介绍
        if(is_page('ssjs')){
        	get_template_part('intro');
        }
        if(is_category('wjhg')){
            get_template_part('history');
        }
    //媒体中心
        if(is_category("3")||is_category("5")||is_category("6")){
            get_template_part('media');
      
        } 
        if(is_page("jxsz")){
        	get_template_part('award');
        }
    ?>
    <?php get_footer(); ?>